<template>
	<view class="avatarBox" :class="class_">
		<view class="flex">
			<u-image width="90rpx" height="90rpx" class="avatarImg" :border-radius="15" :src="ImageUrl(info.avatar)"
				@click="goDetail"></u-image>
			<view @click="goDetail" class="userName">
				<view style="margin-bottom: 0rpx;font-size: 30rpx;font-weight: 600;">{{ info[$t('item.username')] }}
				</view>
				<view class="label-image">
					<u-image class="ui-image" height="30rpx" width="50rpx" v-for="(item,index) in info.label"
						:key="index" :src="ImageUrl(item.url)"></u-image>
				</view>
			</view>

		</view>
		<view class="flex score">
			<view style="padding-left:10rpx">{{ $t('综合评价') }}</view>
			<view>
				<user-rating :num="info.rating" />
			</view>
		</view>
		<slot></slot>
	</view>

</template>
<script>
	import {
		ImageUrl
	} from "@/common/public";
	import UserRating from "@/components/userRating.vue";

	export default {
		components: {
			UserRating
		},
		props: {
			info: {
				type: Object,
				default: {},
				required: true,
			},
			type: {
				type: String | Number,
				default: '1',
			},
			marginTop: {
				type: String | Number,
				default: '',
			}
		},
		data() {
			return {
				lang: '',
				class_: "",
			}
		},
		mounted() {
			this.lang = this.$i18n.locale
			if (this.type == 2) {
				if (this.marginTop == '') {
					this.class_ = '';
				} else {
					this.class_ = ' jian';
				}
			} else {
				if (this.marginTop == '') {
					this.class_ = '';
				} else {
					this.class_ = ' jian';
				}
			}
		},
		computed: {},
		methods: {
			ImageUrl,
			goDetail() {
				this.$u.route({
					url: "/pages/user/homePage/homePage",
					params: {
						id: this.info.id,
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.jian {
		margin-top: -250rpx !important;
		position: absolute;
		left: 5%;
		z-index: 100;
	}

	.avatarBox {
		z-index: 99;
		width: 90%;
		border-radius: 8px;
		padding: 34px 15px;
		margin: 10rpx auto;
		background-color: white;
		position: relative;
		margin-bottom: 16rpx;
	
		&.yellow {
			background: #fefcf6;
		}

		.flex {
			display: flex;
			align-items: center;
			// justify-content: space-between;

			&+.flex {
				margin-top: 40rpx;
				justify-content: space-between;
			}

			.avatarImg {}

			.userName {
				flex: 1;
				font-size: 35rpx;
				// flex: 0 0 240rpx;
				text-align: left;
				margin-left: 20rpx;
			}

			.label-image {
				display: flex;
				flex-wrap: wrap;
				margin-top: 3rpx;
				margin-bottom: 15rpx;

				.ui-image {
					// margin-left: 20rpx;
				}
			}
		}
	}

	.score {
		background-image: url("https://app.gluz.com.cn/uniappAssets/static/newStyleIcon/score.png");
		min-width: 390rpx;
		background-size: 100% 100%;
		height: 44rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		right: 0;
		bottom: 0;
		padding: 0rpx 40rpx;
		font-size: 22rpx;
	}
</style>